<?php
session_start();
include 'connect.php';
if(isset ($_GET['log']))
{
    if($_GET['log']=="out")
    {
        foreach ($_SESSION as $k=>$v)
        {
            $_SESSION[$k]="";
        }
    }
    if(isset ($_COOKIE['Name4']) && isset ($_COOKIE['Pass4']))
    {
        unset ($_COOKIE['Name4']);
        unset ($_COOKIE['Pass4']);
    }
}
if(isset ($_POST['send']))
{
    $name=trim($_POST['name']);
    $pass=trim($_POST['password']);
    $pass=md5($pass);
    $resulSet=mysql_query("select * from `users` where `name`='$name' and `pass`='$pass'");
    $result=mysql_fetch_array($resulSet);
    if(!empty($result['id']))
    {
        $_SESSION['id']=$result['id'];
        $_SESSION['name']=$result['name'];
    }
}
if(!isset($_SESSION['id'])||empty ( $_SESSION['id'])){
?>
<html>
<body>
<form method="post" action="login.php">
name:<input  type="input" name="name" /><br>
password:<input  type="password" name="password"  /><br>
remeber me :<input  type="checkbox" name="rem" value="yes"  /><br>
<input type="submit" value="send" name="send" />
</form>
</body>
<?php
}else{
    header('Location: view.php');
}
?>